const customToolsRepository = {
    async getAllTools() {
        const result = await chrome.storage.local.get('customTools');
        return result.customTools || [];
    },

    async addTool(tool) {
        const tools = await this.getAllTools();
        tools.push({
            id: Date.now().toString(),
            name: tool.name,
            icon: '🔧',
            url: tool.url,
            createdAt: new Date().toISOString()
        });
        await chrome.storage.local.set({ customTools: tools });
        return tools;
    },

    async removeTool(toolId) {
        const tools = await this.getAllTools();
        const updatedTools = tools.filter(tool => tool.id !== toolId);
        await chrome.storage.local.set({ customTools: updatedTools });
        return updatedTools;
    }
};

window.markAnything = window.markAnything || {};
window.markAnything.customToolsRepository = customToolsRepository; 